<template>
  <li>
    <div class="div-tag">
      <p class="p-tag">
        <span>姓名：</span>
        <span class="van-ellipsis">{{ list }}</span>
      </p>
      <p v-show="isShowTag">
        <span>余&nbsp;&nbsp;&nbsp;额：</span>
        <span class="span-primary">￥150.00</span>
      </p>
      <p v-show="!isShowTag">
        <span>收入金额：</span>
        <span class="span-primary">￥150.00</span>
      </p>
    </div>
    <div class="div-tag">
      <p>
        <span>性别：</span>
        <span>女</span>
      </p>
      <p v-show="isShowTag">
        <span>消费额：</span>
        <span class="span-warning">￥150.00</span>
      </p>
    </div>
    <div class="div-tag">
      <p>
        <span>电话：</span>
        <span>13028028781</span>
      </p>
    </div>
    <div class="div-tag">
      <p>
        <span>录入时间：</span>
        <span>2020-09-20</span>
      </p>
    </div>
    <div class="footer-btn">
      <van-button color="#44AFC8" plain round @click="addUser('编辑用户', isShowTag)">编辑</van-button>
      <van-button color="#E44E58" plain round @click="del('张三')">删除</van-button>
    </div>
  </li>
</template>

<script>
export default {
  name: 'UserList',
  props: {
    isShowTag: {
      type: Boolean,
      required: true
    },
    list: {
      type: Number,
      required: true
    }
  },
  methods: {
    addUser(title, isShowTag) {
      this.$router.push({
        path: '/addUser',
        query: {
          title,
          isForbidden: true, // 控制addUser提交按钮是否可以点击
          isShowTag // 0/顾客 1/老师
        }
      })
    },
    del(userName) {
      this.Dialog.confirm({
        message: `是否确认删除<span style="color: red">${userName}</span>的此条记录吗?`
      })
        .then(() => this.Toast('删除成功'))
        .catch(() => this.Toast('取消删除'))
    }
  }
}
</script>

<style scoped lang="less" rel="stylesheet/less">
li {
  margin: 5px 0;
  background-color: #F5F1F0;
  padding: 5px 15px;
  box-sizing: border-box;
  font-size: 12px;

  .div-tag {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0 0 0;
    box-sizing: border-box;

    .p-tag {
      display: flex;

      span:nth-child(2) {
        width: 100px;
      }
    }

    .span {
      &-primary {
        color: #00BF35;
      }

      &-warning {
        color: #F39209;
      }
    }

  }

  .footer-btn {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;

    button {
      height: 22px;
    }

    button:nth-child(1) {
      margin-right: 15px;
    }
  }
}
</style>
